package com.xilihui.xlh.business.requests;

import com.xilihui.xlh.business.entities.AddressEntity;
import com.xilihui.xlh.business.entities.CommentEntity;
import com.xilihui.xlh.business.entities.ConfirmOrderEntity;
import com.xilihui.xlh.business.entities.HotKeyEntity;
import com.xilihui.xlh.business.entities.MyEvaluationEntity;
import com.xilihui.xlh.business.entities.NearbyStoreEntity;
import com.xilihui.xlh.business.entities.PayEntity;
import com.xilihui.xlh.business.entities.RecommendGoodEntity;
import com.xilihui.xlh.business.entities.RefundEntity;
import com.xilihui.xlh.business.entities.SearchGoodsEntity;
import com.xilihui.xlh.business.entities.SpecEntity;
import com.xilihui.xlh.business.entities.StoreCartListEntity;
import com.xilihui.xlh.business.entities.StoreClassEntity;
import com.xilihui.xlh.business.entities.StoreDetailsEntity;
import com.xilihui.xlh.business.entities.StoreGetPay;
import com.xilihui.xlh.business.entities.StoreGoodDetailsEntity;
import com.xilihui.xlh.business.entities.StoreHomeDataEntity;
import com.xilihui.xlh.business.entities.StoreMyOrderEntity;
import com.xilihui.xlh.core.app.BaseEntity;


import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import rx.Observable;

/**
 * Created by Administrator on 2018/9/3.
 */

public interface StoreService {

    /**
     * 商城首页
     * @param temptime
     * @param app_key
     * @param page
     * @param sign
     * @return
     */
    @FormUrlEncoded
    @POST("/api/goods/index")
    Observable<StoreHomeDataEntity> home(
            @Field("temptime") String temptime,
            @Field("app_key") String app_key,
            @Field("page") int page,
            @Field("sign") String sign
    );

    /**
     * 商城首页分类
     * @param cate_id
     * @param temptime
     * @param app_key
     * @param page
     * @param sign
     * @return
     */
    @FormUrlEncoded
    @POST("/api/goods/get_goods_by_category")
    Observable<StoreClassEntity> goodClass(
            @Field("cate_id") String cate_id,
            @Field("temptime") String temptime,
            @Field("app_key") String app_key,
            @Field("page") int page,
            @Field("sign") String sign
    );

    /**
     * 商品详情
     * @param goods_id
     * @param temptime
     * @param app_key
     * @param sign
     * @return
     */
    @FormUrlEncoded
    @POST("/api/goods/goods_info")
    Observable<StoreDetailsEntity> details(
            @Field("access_token") String access_token,
            @Field("goods_id") String goods_id,
            @Field("temptime") String temptime,
            @Field("app_key") String app_key,
            @Field("sign") String sign
    );

    /**
     * 全部评价
     * @param goods_id
     * @param temptime
     * @param app_key
     * @param page
     * @param sign
     * @return
     */
    @FormUrlEncoded
    @POST("/api/comment/get_comment_by_goods_id")
    Observable<CommentEntity> comment(
            @Field("goods_id") String goods_id,
            @Field("temptime") String temptime,
            @Field("app_key") String app_key,
            @Field("page") int page,
            @Field("sign") String sign
    );

    /**
     * 商城搜索
     * @param keyword
     * @param orderby
     * @param temptime
     * @param app_key
     * @param page
     * @param sign
     * @return
     */
    @FormUrlEncoded
    @POST("/api/goods/search_goods")
    Observable<SearchGoodsEntity> searchGoods(
            @Field("keyword") String keyword,
            @Field("orderby") String orderby,
            @Field("temptime") String temptime,
            @Field("app_key") String app_key,
            @Field("page") int page,
            @Field("sign") String sign
    );
    
    
    /**
     * 商品详情 -规格
     * @param key
     * @param goods_id
     * @param temptime
     * @param app_key
     * @return
     */
    @FormUrlEncoded
    @POST("/api/spec_goods_price/get_price")
    Observable<SpecEntity> guige(
            @Field("key") String key,
            @Field("goods_id") String goods_id,
            @Field("temptime") String temptime,
            @Field("app_key") String app_key,
            @Field("sign") String sign
    );

    /**
     * 商城 加入购物车
     * @param access_token
     * @param goods_id
     * @param goods_num
     * @param item_id
     * @return
     */
    @FormUrlEncoded
    @POST("/api/cart/add_cart")
    Observable<BaseEntity> addCart(
            @Field("access_token") String access_token,
            @Field("goods_id") String goods_id,
            @Field("goods_num") String goods_num,
            @Field("item_id") String item_id
    );

    /**
     * 购物车 列表
     * @param access_token
     * @return
     */
    @FormUrlEncoded
    @POST("/api/cart/cart_list")
    Observable<StoreCartListEntity> cartList(
            @Field("access_token") String access_token
    );

    
    /**
     * 收货地址 列表
     * @param access_token
     * @return
     */
    @FormUrlEncoded
    @POST("/api/user_address/get_address_list")
    Observable<AddressEntity> address(
            @Field("access_token") String access_token
    );

    /**
     * 更新购物车
     * @param access_token
     * @param id
     * @param item_id
     * @param goods_num
     * @return
     */
    @FormUrlEncoded
    @POST("/api/cart/update_cart")
    Observable<BaseEntity> updateCart(
            @Field("access_token") String access_token,
            @Field("id") String id,
            @Field("item_id") String item_id,
            @Field("goods_num") String goods_num
    );
    
    /**
     * 添加 收货地址
     * @param access_token
     * @param consignee
     * @param province
     * @param city
     * @param district
     * @param mobile
     * @param is_default
     * @param address
     * @return
     */
    @FormUrlEncoded
    @POST("/api/user_address/add_address")
    Observable<BaseEntity> addAddress(
            @Field("access_token") String access_token,
            @Field("consignee") String consignee,
            @Field("province") String province,
            @Field("city") String city,
            @Field("district") String district,
            @Field("mobile") String mobile,
            @Field("is_default") String is_default,
            @Field("address") String address
    );

    /**
     * 删除 收货地址
     * @param access_token
     * @param address_id
     * @return
     */
    @FormUrlEncoded
    @POST("/api/user_address/delete_address")
    Observable<BaseEntity> deleteAddress(
            @Field("access_token") String access_token,
            @Field("address_id") String address_id
    );

    /**
     * 修改收货地址
     * @param access_token
     * @param address_id
     * @param consignee
     * @param province
     * @param city
     * @param district
     * @param mobile
     * @param is_default
     * @param address
     * @return
     */
    @FormUrlEncoded
    @POST("/api/user_address/update_address")
    Observable<BaseEntity> updateAddress(
            @Field("access_token") String access_token,
            @Field("address_id") String address_id,
            @Field("consignee") String consignee,
            @Field("province") String province,
            @Field("city") String city,
            @Field("district") String district,
            @Field("mobile") String mobile,
            @Field("is_default") String is_default,
            @Field("address") String address
    );

    /**
     * 商品推荐
     * @param temptime
     * @param app_key
     * @param page
     * @param sign
     * @return
     */
    @FormUrlEncoded
    @POST("/api/goods/get_recommend_goods")
    Observable<RecommendGoodEntity> recommendGoods(
            @Field("temptime") String temptime,
            @Field("app_key") String app_key,
            @Field("page") String page,
            @Field("sign") String sign
    );

    /**
     * 商品規格
     * @param id
     * @param access_token
     * @return
     */
    @FormUrlEncoded
    @POST("/api/cart/goods_info")
    Observable<StoreDetailsEntity> goodsInfo(
            @Field("id") String id,
            @Field("access_token") String access_token
    );

    /**
     * 勾选单个商品
     * @param access_token
     * @param id
     * @param selected
     * @return
     */
    @FormUrlEncoded
    @POST("/api/cart/selected")
    Observable<BaseEntity> select(
            @Field("access_token") String access_token,
            @Field("id") String id,
            @Field("selected") String selected
    );

    /**
     * 全选商品
     * @param access_token
     * @param selected
     * @return
     */
    @FormUrlEncoded
    @POST("/api/cart/select_all")
    Observable<BaseEntity> selectAll(
            @Field("access_token") String access_token,
            @Field("selected") String selected
    );

    /**
     * 确认订单
     * @param access_token
     * @param temptime
     * @param app_key
     * @return
     */
    @FormUrlEncoded
    @POST("/api/cart/balance")
    Observable<ConfirmOrderEntity> confirmOrder(
            @Field("access_token") String access_token,
            @Field("temptime") String temptime,
            @Field("app_key") String app_key,
            @Field("sign") String sign
    );

    /**
     * 商品详情-立即购买
     * @param access_token
     * @param goods_id
     * @param goods_num
     * @param item_id
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/balance_now_confirm")
    Observable<ConfirmOrderEntity> lijibuy(
            @Field("access_token") String access_token,
            @Field("goods_id") String goods_id,
            @Field("goods_num") String goods_num,
            @Field("item_id") String item_id
    );

    /**
     * 删除商品
     * @param access_token
     * @param temptime
     * @param app_key
     * @param sign
     * @return
     */
    @FormUrlEncoded
    @POST("/api/cart/delete_cart")
    Observable<BaseEntity> deleteCart(
           @Field("access_token") String access_token,
           @Field("temptime") String temptime,
           @Field("app_key") String app_key,
           @Field("sign") String sign
    );

    /**
     * 收藏商品
     * @param access_token
     * @param id
     * @param collect
     * @return
     */
    @FormUrlEncoded
    @POST("/api/goods/collect_goods")
    Observable<BaseEntity> collectCart(
           @Field("access_token") String access_token,
           @Field("id") String id,
           @Field("collect") String collect
    );

    /**
     * 唤起支付
     * @param access_token
     * @param goods
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/add_order")
    Observable<StoreGetPay> addOrder(
            @Field("access_token") String access_token,
            @Field("address_id") String address_id,
            @Field("type") String type,
            @Field("goods") String goods
    );

    /**
     * 支付
     * @param access_token
     * @param order_all_sn
     * @param code
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/pay")
    Observable<PayEntity> pay(
            @Field("access_token") String access_token,
            @Field("order_all_sn") String order_all_sn,
            @Field("code") String code
    );

    /**
     * 商城 我的订单
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/order_list")
    Observable<StoreMyOrderEntity> storeOrderf(
            @Field("access_token") String access_token,
            @Field("status") String status,
            @Field("page") int page
    );

    /**
     * 取消订单
     * @param access_toekn
     * @param id
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/cancel_order_all")
    Observable<BaseEntity> cancelOrder(
            @Field("access_token") String access_toekn,
            @Field("id") String id
    );
    
    /**
     * 删除订单
     * @param access_token
     * @param id
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/delete_order")
    Observable<BaseEntity> deleteOrder(
            @Field("access_token") String access_token,
            @Field("id") String id
    );

    /**
     * 订单详情
     * @param access_token
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/order_info")
    Observable<StoreGoodDetailsEntity> orderAllInfo(
            @Field("access_token") String access_token,
            @Field("order_id") String order_id,
            @Field("order_all_id") String order_all_id
    );
    

    /**
     * 评价商品
     * @param id
     * @param content
     * @param zan_num
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/comment")
    Observable<BaseEntity> comment(
            @Field("access_token") String access_token,
            @Field("id") String id,
            @Field("content") String content,
            @Field("zan_num") String zan_num
    );

    /**
     * 我的评价
     * @param access_token
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("/api/comment/get_comment_by_user")
    Observable<MyEvaluationEntity> commentList(
            @Field("access_token") String access_token,
            @Field("page") int page
    );

    /**
     * 确认收货
     * @param access_token
     * @param id
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/confirm_receipt")
    Observable<BaseEntity> confirmReceipt(
            @Field("access_token") String access_token,
            @Field("id") String id
    );

    /**
     * 获取附近门店
     * @param lat
     * @param lng
     * @param agent_id
     * @return
     */
    @FormUrlEncoded
    @POST("/api/agent/get_agents_by_parent")
    Observable<NearbyStoreEntity> nearbyStores(
            @Field("lat") String lat,
            @Field("lng") String lng,
            @Field("agent_id") String agent_id,
            @Field("page") int page
    );

    /**
     * 热门搜索 keywords
     * @return
     */
    @GET("/api/search_word/get_keywords")
    Observable<HotKeyEntity> keywords();

    /**
     * 退款详情
     * @param access_token
     * @param order_id
     * @return
     */
    @FormUrlEncoded
    @POST("/api/return_goods/info")
    Observable<RefundEntity> returnGoods(
            @Field("access_token") String access_token,
            @Field("id") String order_id
    );

    /**
     * 退款申请 
     * @param access_token
     * @param order_id
     * @param reason
     * @return
     */
    @FormUrlEncoded
    @POST("/api/order/apply_refund")
    Observable<BaseEntity> applyRefund(
            @Field("access_token") String access_token,
            @Field("order_id") String order_id,
            @Field("reason") String reason
    );

    /**
     * 撤销退款
     * @param access_token
     * @param id
     * @return
     */
    @FormUrlEncoded
    @POST("/api/return_goods/cancel_return")
    Observable<BaseEntity> cancelReturn(
            @Field("access_token") String access_token,
            @Field("id") String id
    );
    
}
